<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 100px;
            height: 100px;
            background-color: #f00;
        }
    </style>
</head>
<body>
    <div id="app">
        <!-- window的东西无法直接写到行内 -->
        <!-- 因为行内的this指向的这个vue对象 -->
        <!-- <button v-on:click="fn1">点我啊</button>
        <button v-on:click="add">加1</button> -->
        
        <!-- 简写形式：把v-on:换成@ -->
        <button @click="fn1">点我啊</button>
        <button @click="add">加1</button>

        <!-- 在行内不用加this -->
        <!-- <button v-on:click="count++">加1 -- 写到行内</button>
        <div v-on:mouseenter="fn2" v-on:mouseleave="fn3" class="box">
            {{ count }}
        </div> -->
        <button @click="count++">加1 -- 写到行内</button>
        <div @mouseenter="fn2" @mouseleave="fn3" class="box">
            {{ count }}
        </div>


    </div>
    <script src="./vue.js"></script>
    <script>
        new Vue({
            el:'#app',
            data: {
                count: 0
            },
            // 放方法的地方
            methods: {
                fn1 () {
                    alert('点一次200')
                },

                fn2 () {
                    alert('我进来了')
                },

                fn3 () {
                    alert('我出去了')
                },
                
                add () {
                    // 注意：在vue的方法中要访问data中的数据，必须前面加this
                    this.count++
                }
            }
        })
    </script>
</body>
</html>